package com.leo;

import javafx.application.Application;
import javafx.stage.Modality;
import javafx.stage.Stage;

/**
 * @ClassName ThirdStageModalWindow
 * @Description 模态窗口，不关闭其他窗口无法使用
 * @Author wangss
 * @date 2020.05.16 00:10
 * @Version 1.0
 */
public class ThirdStageModalWindow extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) throws Exception {
        Stage stage1 = new Stage();
        stage1.setTitle("stage1");
        stage1.show();

        Stage stage2 = new Stage();
        stage2.setTitle("stage2");
        // 这两个配合使用，stage2是stage1的模态窗口
        stage2.initOwner(stage1);
        stage2.initModality(Modality.WINDOW_MODAL);

        stage2.show();

        Stage stage3 = new Stage();
        stage3.setTitle("stage3");
        stage3.show();

        Stage stage4 = new Stage();
        stage4.setTitle("stage4");
        stage4.show();

        Stage stage5 = new Stage();
        stage5.setTitle("stage5");
        // 设置模态窗口
        stage5.initModality(Modality.APPLICATION_MODAL);
        stage5.show();

    }
}
